#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#include "vector.h"

class test_std_vector
{	
public:
	void test1()
	{
		vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);

		for (size_t i = 0; i < v1.size(); i++)
		{
			cout << v1[i] << ' ';
		}
		cout << endl;

		vector<int> v2(v1.begin(), v1.end());
		for (size_t i = 0; i < v2.size(); i++)
		{
			cout << v2[i] << ' ';
		}
		cout << endl;

		string str = "He had an argument with his family!!!";
		vector<char> v3(str.begin(), str.end());
		for (auto e : v3)
		{
			cout << e;
		}
		cout << endl;
		auto pos = find(v3.begin(), v3.end(), ' ');
		while (pos != v3.end())
		{
			pos = v3.erase(pos);
			pos = find(pos, v3.end(), ' ');
		}
		for (auto e : v3)
		{
			cout << e;
		}
		cout << endl;
		sort(v3.rbegin(), v3.rend());
		for (auto e : v3)
		{
			cout << e;
		}
		cout << endl;
	}
	void test2()
	{
		string str = "It was a wild night";
		vector<char> v1(str.begin(), str.end());
		// cout << v1[str.size()] << endl;
		for (auto i : v1)
		{
			cout << i;
		}
		cout << endl;
		v1.insert(v1.begin() + 128, 5, '!');
		for (auto i : v1)
		{
			cout << i;
		}
		cout << endl;
		v1.erase(v1.begin() + 15, v1.end());
		/*cout << v1.at(256) << endl;*/
		/*v1.erase(v1.end());*/
	}
	void test3()
	{
		string str = "It was a wild night";
		vector<char> v1(str.begin(), str.end());
		cout << v1.capacity() << endl;

		v1.clear();
		cout << v1.capacity() << endl;
		v1.pop_back();
	}
	void test4()
	{
		/*vector<int> v(5);
		const vector<int>::iterator it = v.begin();
		++it;*/
	}
};
class test_simulation_vector
{
public:
	void test1()
	{
		simulation::vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		v1.push_back(6);
		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
		auto v1_it = v1.begin();
		while (v1_it != v1.end())
		{
			cout << *v1_it << ' ';
			++v1_it;
		}
		cout << endl;
		for (size_t i = 0; i < v1.size(); i++)
		{
			v1[i]++;
		}
		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
	}
	void test2()
	{
		simulation::vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		v1.push_back(6);
		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
		auto pos = v1.begin();
		v1.insert(pos, 100);

		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
		auto pos_1 = v1.begin() + 2;
		while (pos_1 != v1.end())
		{
			pos_1 = v1.erase(pos_1);
		}
		for (auto& e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
	}
	void test3()
	{
		simulation::vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		v1.push_back(6);
		simulation::vector<int> v2;
		v2.push_back(12);
		v2.push_back(22);
		v2.push_back(32);
		v2.push_back(42);
		v2.push_back(52);
		v2.push_back(62);
		v2.resize(15, 10);
		for (auto e : v2)
		{
			cout << e << ' ';
		}
		cout << endl;
		v2.resize(12, 8);
		for (auto e : v2)
		{
			cout << e << ' ';
		}
		cout << endl;
		v2.resize(v2.capacity() * 2, 37);
		for (auto e : v2)
		{
			cout << e << ' ';
		}
		cout << endl;
		while (!v2.empty())
		{
			v2.pop_back();
		}
		for (auto e : v2)
		{
			cout << e << ' ';
		}
		cout << endl;
	}
	void test4()
	{
		simulation::vector<int> v1;
		v1.push_back(1);
		v1.push_back(2);
		v1.push_back(3);
		v1.push_back(4);
		v1.push_back(5);
		v1.push_back(6);
		v1.push_back(7);
		v1.push_back(8);
		v1.push_back(9);
		simulation::vector<int> v2(v1);
		for (auto e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
		v2.insert(v2.begin(), 7);
		v1 = v2;
		for (auto e : v1)
		{
			cout << e << ' ';
		}
		cout << endl;
	}
	void test5()
	{
		simulation::vector<string> v1;
		v1.push_back("abc");
		v1.push_back("die");
		v1.push_back("boundary");
		v1.push_back("phil");
		v1.push_back("type");
		v1.push_back("budget");
		v1.push_back("double");
		v1.push_back("behave");
		v1.push_back("technique");
		for (auto& i : v1)
		{
			cout << i << ' ';
		}
		cout << endl;
		simulation::vector<string>::reverse_iterator it = v1.rbegin();
		while (it != v1.rend())
		{
			cout << *it << ' ';
			++it;
		}
		cout << endl;
	}
	void test6()
	{
		string str = "He had an argument with his family!!!";
		simulation::vector<int> v2(5, 32);
		simulation::vector<int> v1((size_t)5, 32);
		for (auto e : v1)
		{
			cout << e << ' ';
		}
		cout << endl << endl;
		simulation::vector<char> v3(str.begin(), str.end());
		for (auto e : v3)
		{
			cout << e;
		}
		cout << endl;
	}
	void test7()
	{
		/*simulation::vector<int> v(5);
		const simulation::vector<int>::iterator it = v.begin();
		++it;*/
	}
};
int main()
{
	test_simulation_vector().test5();

	return 0;
}